<%@page import="classes.Student"%>
<%@page import="classes.Classmate"%>
<%@page import="classes.Teacher"%>
<%@page import="classes.MyDreamList"%>
<%@page import="classes.AcademicList"%>

<%
  request.setAttribute("page", "profile");
  if( session.getAttribute("validated")  == null ) {
    response.sendRedirect("Login.jsp");
  }

  String sid = request.getParameter("sid");
  Student s = new Student(Integer.parseInt(sid));
  s.loadData();
  session.setAttribute( "userName",s.getUserName());
%>

<script>

function editBio() {
	
	$(".editBio").show();
	$(".userBio").hide();
}

function cancel(section) {
	if( section == 'bio') {
		$(".editBio").hide();
		$(".userBio").show();
	}
}

function updateBio() {
	var text = $("#bioText").val();
	$.ajax({  type:   "POST",
		      url:    "ProfiileAjax.jsp",
		      data:   "bio="+text+"&sid=<%=sid%>",  
		      success: function(html) {		
		        $(".editBio").hide();
		        $(".userBio").html(html);
		        $(".userBio").show();
          }
    });
}

function uploadImage() {
    var popup = window.open('ImagePopup.jsp?sid=<%=sid%>', '', 'scrollbars,resizable,height=200,width=400');
}


</script>

<jsp:include page="profile_header.jsp" flush="true"/>
<div class="mainContent">
  <div class="title">My Profile</div>
  <div class = "profile-image">       
    <img id="image" src="images/<%=s.picture_location%>"/>
    <div class="upload" onclick="uploadImage()">Upload Image</div>
  </div>
  <div class="bio border">
    <span class="heading">About Me</span>
    <span class="edit" onclick="editBio()">Edit</span>
    <div class="userBio"><%=s.bio %></div>
    <div class="editBio">
      <textarea id="bioText" cols="45" rows="7" name="bio"><%=s.bio %></textarea><br><br>
      <span class="edit" onclick="updateBio()">Save</span>
      <span class="edit" onclick="cancel('bio')">Cancel</span>
    </div>
  </div>

  <div class="references border">
    <table width="100%">
      <tr>
        <td onclick="changeProfile('classmates')">My Classmates</td>
        <td>(<%=s.classmates.size()%>)</td>
      </tr>
      <tr>
        <td onclick="changeProfile('teachers')">My Teachers</td>
        <td>(<%=s.teachers.size()%>)</td>
	  </tr>
      <tr>
        <td onclick="changeProfile('dreamlist')">My Dreamlist</td>
        <td>(<%=s.dreamlist.size()%>)</td>
      </tr> 
	  <tr>    
	    <td>My Transcripts</td>
	    <td>(0)</td>  
	  </tr>
	  <tr>  
	    <td>My Recommendations</td>
        <td>(0)</td>
      </tr>
	  <tr>  
        <td>My Activities</td>
	    <td>(0)</td>
	  </tr>    
	</table>    
    <br>
    <img id="xx" width="50" height="50" src="images/house.gif"/><%=s.school_name%>,<%=s.location%>
    <br>
    <a href="#">schooledin.com/<%=s.schooledinid%></a>
  </div>
  
  <div class="preferences">
    <input type="checkbox" id="dobp"/>
    <label for="dobp">DOB Public</label><br>
    <input type="checkbox" id="sidp"/>
    <label for="sidp">SchooledIn Id Public</label><br>
    <input type="checkbox" id="biop"/>
    <label for="biop">Bio Public</label>
  </div>
</div>
<div class = "end-home"></div>
<jsp:include page="footer.jsp" flush="true"/>